<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    
    <title>Input and output &mdash; NumPy v1.18 Manual</title>
    
    <link rel="stylesheet" type="text/css" href="../_static/css/spc-bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../_static/css/spc-extend.css">
    <link rel="stylesheet" href="../_static/scipy.css" type="text/css" >
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" >
    <link rel="stylesheet" href="../_static/graphviz.css" type="text/css" >
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.18.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  false
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <script type="text/javascript" src="../_static/js/copybutton.js"></script>
    <link rel="author" title="About these documents" href="../about.html" >
    <link rel="index" title="Index" href="../genindex.html" >
    <link rel="search" title="Search" href="../search.html" >
    <link rel="top" title="NumPy v1.18 Manual" href="../index.html" >
    <link rel="up" title="Routines" href="routines.html" >
    <link rel="next" title="numpy.load" href="generated/numpy.load.html" >
    <link rel="prev" title="numpy.lib.Arrayterator" href="generated/numpy.lib.Arrayterator.html" > 
  </head>
  <body>
<div class="container">
  <div class="top-scipy-org-logo-header" style="background-color: #a2bae8;">
    <a href="../index.html">
      <img border=0 alt="NumPy" src="../_static/numpy_logo.png"></a>
    </div>
  </div>
</div>


    <div class="container">
      <div class="main">
        
	<div class="row-fluid">
	  <div class="span12">
	    <div class="spc-navbar">
              
    <ul class="nav nav-pills pull-left">
        <li class="active"><a href="https://numpy.org/">NumPy.org</a></li>
        <li class="active"><a href="https://numpy.org/doc">Docs</a></li>
        
        <li class="active"><a href="../index.html">NumPy v1.18 Manual</a></li>
        

          <li class="active"><a href="index.html" >NumPy Reference</a></li>
          <li class="active"><a href="routines.html" accesskey="U">Routines</a></li> 
    </ul>
              
              
    <ul class="nav nav-pills pull-right">
      <li class="active">
        <a href="../genindex.html" title="General Index"
           accesskey="I">index</a>
      </li>
      <li class="active">
        <a href="generated/numpy.load.html" title="numpy.load"
           accesskey="N">next</a>
      </li>
      <li class="active">
        <a href="generated/numpy.lib.Arrayterator.html" title="numpy.lib.Arrayterator"
           accesskey="P">previous</a>
      </li>
    </ul>
              
	    </div>
	  </div>
	</div>
        

	<div class="row-fluid">
      <div class="spc-rightsidebar span3">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Input and output</a><ul>
<li><a class="reference internal" href="#numpy-binary-files-npy-npz">NumPy binary files (NPY, NPZ)</a></li>
<li><a class="reference internal" href="#text-files">Text files</a></li>
<li><a class="reference internal" href="#raw-binary-files">Raw binary files</a></li>
<li><a class="reference internal" href="#string-formatting">String formatting</a></li>
<li><a class="reference internal" href="#memory-mapping-files">Memory mapping files</a></li>
<li><a class="reference internal" href="#text-formatting-options">Text formatting options</a></li>
<li><a class="reference internal" href="#base-n-representations">Base-n representations</a></li>
<li><a class="reference internal" href="#data-sources">Data sources</a></li>
<li><a class="reference internal" href="#binary-format-description">Binary Format Description</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="generated/numpy.lib.Arrayterator.html"
                        title="previous chapter">numpy.lib.Arrayterator</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="generated/numpy.load.html"
                        title="next chapter">numpy.load</a></p>
<div id="searchbox" style="display: none" role="search">
  <h4>Quick search</h4>
    <div>
    <form class="search" action="../search.html" method="get">
      <input type="text" style="width: inherit;" name="q" />
      <input type="submit" value="search" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
          <div class="span9">
            
        <div class="bodywrapper">
          <div class="body" id="spc-section-body">
            
  <div class="section" id="input-and-output">
<h1>Input and output<a class="headerlink" href="#input-and-output" title="Permalink to this headline">¶</a></h1>
<div class="section" id="numpy-binary-files-npy-npz">
<h2>NumPy binary files (NPY, NPZ)<a class="headerlink" href="#numpy-binary-files-npy-npz" title="Permalink to this headline">¶</a></h2>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.load.html#numpy.load" title="numpy.load"><code class="xref py py-obj docutils literal notranslate"><span class="pre">load</span></code></a>(file[, mmap_mode, allow_pickle, …])</p></td>
<td><p>Load arrays or pickled objects from <code class="docutils literal notranslate"><span class="pre">.npy</span></code>, <code class="docutils literal notranslate"><span class="pre">.npz</span></code> or pickled files.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.save.html#numpy.save" title="numpy.save"><code class="xref py py-obj docutils literal notranslate"><span class="pre">save</span></code></a>(file, arr[, allow_pickle, fix_imports])</p></td>
<td><p>Save an array to a binary file in NumPy <code class="docutils literal notranslate"><span class="pre">.npy</span></code> format.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.savez.html#numpy.savez" title="numpy.savez"><code class="xref py py-obj docutils literal notranslate"><span class="pre">savez</span></code></a>(file, \*args, \*\*kwds)</p></td>
<td><p>Save several arrays into a single file in uncompressed <code class="docutils literal notranslate"><span class="pre">.npz</span></code> format.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.savez_compressed.html#numpy.savez_compressed" title="numpy.savez_compressed"><code class="xref py py-obj docutils literal notranslate"><span class="pre">savez_compressed</span></code></a>(file, \*args, \*\*kwds)</p></td>
<td><p>Save several arrays into a single file in compressed <code class="docutils literal notranslate"><span class="pre">.npz</span></code> format.</p></td>
</tr>
</tbody>
</table>
<p>The format of these binary file types is documented in
<a class="reference internal" href="generated/numpy.lib.format.html#module-numpy.lib.format" title="numpy.lib.format"><code class="xref py py-mod docutils literal notranslate"><span class="pre">numpy.lib.format</span></code></a></p>
</div>
<div class="section" id="text-files">
<h2>Text files<a class="headerlink" href="#text-files" title="Permalink to this headline">¶</a></h2>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.loadtxt.html#numpy.loadtxt" title="numpy.loadtxt"><code class="xref py py-obj docutils literal notranslate"><span class="pre">loadtxt</span></code></a>(fname[, dtype, comments, delimiter, …])</p></td>
<td><p>Load data from a text file.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.savetxt.html#numpy.savetxt" title="numpy.savetxt"><code class="xref py py-obj docutils literal notranslate"><span class="pre">savetxt</span></code></a>(fname, X[, fmt, delimiter, newline, …])</p></td>
<td><p>Save an array to a text file.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.genfromtxt.html#numpy.genfromtxt" title="numpy.genfromtxt"><code class="xref py py-obj docutils literal notranslate"><span class="pre">genfromtxt</span></code></a>(fname[, dtype, comments, …])</p></td>
<td><p>Load data from a text file, with missing values handled as specified.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.fromregex.html#numpy.fromregex" title="numpy.fromregex"><code class="xref py py-obj docutils literal notranslate"><span class="pre">fromregex</span></code></a>(file, regexp, dtype[, encoding])</p></td>
<td><p>Construct an array from a text file, using regular expression parsing.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.fromstring.html#numpy.fromstring" title="numpy.fromstring"><code class="xref py py-obj docutils literal notranslate"><span class="pre">fromstring</span></code></a>(string[, dtype, count, sep])</p></td>
<td><p>A new 1-D array initialized from text data in a string.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.ndarray.tofile.html#numpy.ndarray.tofile" title="numpy.ndarray.tofile"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ndarray.tofile</span></code></a>(fid[, sep, format])</p></td>
<td><p>Write array to a file as text or binary (default).</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.ndarray.tolist.html#numpy.ndarray.tolist" title="numpy.ndarray.tolist"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ndarray.tolist</span></code></a>()</p></td>
<td><p>Return the array as an <code class="docutils literal notranslate"><span class="pre">a.ndim</span></code>-levels deep nested list of Python scalars.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="raw-binary-files">
<h2>Raw binary files<a class="headerlink" href="#raw-binary-files" title="Permalink to this headline">¶</a></h2>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.fromfile.html#numpy.fromfile" title="numpy.fromfile"><code class="xref py py-obj docutils literal notranslate"><span class="pre">fromfile</span></code></a>(file[, dtype, count, sep, offset])</p></td>
<td><p>Construct an array from data in a text or binary file.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.ndarray.tofile.html#numpy.ndarray.tofile" title="numpy.ndarray.tofile"><code class="xref py py-obj docutils literal notranslate"><span class="pre">ndarray.tofile</span></code></a>(fid[, sep, format])</p></td>
<td><p>Write array to a file as text or binary (default).</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="string-formatting">
<h2>String formatting<a class="headerlink" href="#string-formatting" title="Permalink to this headline">¶</a></h2>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.array2string.html#numpy.array2string" title="numpy.array2string"><code class="xref py py-obj docutils literal notranslate"><span class="pre">array2string</span></code></a>(a[, max_line_width, precision, …])</p></td>
<td><p>Return a string representation of an array.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.array_repr.html#numpy.array_repr" title="numpy.array_repr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">array_repr</span></code></a>(arr[, max_line_width, precision, …])</p></td>
<td><p>Return the string representation of an array.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.array_str.html#numpy.array_str" title="numpy.array_str"><code class="xref py py-obj docutils literal notranslate"><span class="pre">array_str</span></code></a>(a[, max_line_width, precision, …])</p></td>
<td><p>Return a string representation of the data in an array.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.format_float_positional.html#numpy.format_float_positional" title="numpy.format_float_positional"><code class="xref py py-obj docutils literal notranslate"><span class="pre">format_float_positional</span></code></a>(x[, precision, …])</p></td>
<td><p>Format a floating-point scalar as a decimal string in positional notation.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.format_float_scientific.html#numpy.format_float_scientific" title="numpy.format_float_scientific"><code class="xref py py-obj docutils literal notranslate"><span class="pre">format_float_scientific</span></code></a>(x[, precision, …])</p></td>
<td><p>Format a floating-point scalar as a decimal string in scientific notation.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="memory-mapping-files">
<h2>Memory mapping files<a class="headerlink" href="#memory-mapping-files" title="Permalink to this headline">¶</a></h2>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.memmap.html#numpy.memmap" title="numpy.memmap"><code class="xref py py-obj docutils literal notranslate"><span class="pre">memmap</span></code></a></p></td>
<td><p>Create a memory-map to an array stored in a <em>binary</em> file on disk.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="text-formatting-options">
<h2>Text formatting options<a class="headerlink" href="#text-formatting-options" title="Permalink to this headline">¶</a></h2>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.set_printoptions.html#numpy.set_printoptions" title="numpy.set_printoptions"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_printoptions</span></code></a>([precision, threshold, …])</p></td>
<td><p>Set printing options.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.get_printoptions.html#numpy.get_printoptions" title="numpy.get_printoptions"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_printoptions</span></code></a>()</p></td>
<td><p>Return the current print options.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.set_string_function.html#numpy.set_string_function" title="numpy.set_string_function"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_string_function</span></code></a>(f[, repr])</p></td>
<td><p>Set a Python function to be used when pretty printing arrays.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.printoptions.html#numpy.printoptions" title="numpy.printoptions"><code class="xref py py-obj docutils literal notranslate"><span class="pre">printoptions</span></code></a>(\*args, \*\*kwargs)</p></td>
<td><p>Context manager for setting print options.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="base-n-representations">
<h2>Base-n representations<a class="headerlink" href="#base-n-representations" title="Permalink to this headline">¶</a></h2>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.binary_repr.html#numpy.binary_repr" title="numpy.binary_repr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">binary_repr</span></code></a>(num[, width])</p></td>
<td><p>Return the binary representation of the input number as a string.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="generated/numpy.base_repr.html#numpy.base_repr" title="numpy.base_repr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">base_repr</span></code></a>(number[, base, padding])</p></td>
<td><p>Return a string representation of a number in the given base system.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="data-sources">
<h2>Data sources<a class="headerlink" href="#data-sources" title="Permalink to this headline">¶</a></h2>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.DataSource.html#numpy.DataSource" title="numpy.DataSource"><code class="xref py py-obj docutils literal notranslate"><span class="pre">DataSource</span></code></a>([destpath])</p></td>
<td><p>A generic data source file (file, http, ftp, …).</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="binary-format-description">
<h2>Binary Format Description<a class="headerlink" href="#binary-format-description" title="Permalink to this headline">¶</a></h2>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="generated/numpy.lib.format.html#module-numpy.lib.format" title="numpy.lib.format"><code class="xref py py-obj docutils literal notranslate"><span class="pre">lib.format</span></code></a></p></td>
<td><p>Binary serialization</p></td>
</tr>
</tbody>
</table>
</div>
</div>


          </div>
        </div>
          </div>
        </div>
      </div>
    </div>

    <div class="container container-navbar-bottom">
      <div class="spc-navbar">
        
      </div>
    </div>
    <div class="container">
    <div class="footer">
    <div class="row-fluid">
    <ul class="inline pull-left">
      <li>
        &copy; Copyright 2008-2019, The SciPy community.
      </li>
      <li>
      Last updated on Feb 20, 2020.
      </li>
      <li>
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 2.4.2.
      </li>
    </ul>
    </div>
    </div>
    </div>
  </body>
</html>